package com.book.book.service.impl;

import com.book.iphone.domain.ImgUrlSplitUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.book.book.dao.ApplyDao;
import com.book.book.domain.ApplyDO;
import com.book.book.service.ApplyService;



@SuppressWarnings("SpringJavaAutowiringInspection")
@Service
public class ApplyServiceImpl implements ApplyService {
	@Autowired
	private ApplyDao applyDao;
	
	@Override
	public ApplyDO get(Integer id){
		return applyDao.get(id);
	}
	
	@Override
	public List<ApplyDO> list(Map<String, Object> map){
		return applyDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return applyDao.count(map);
	}
	
	@Override
	public int save(ApplyDO apply){
		apply.setUpDate(new Date());
		return applyDao.save(apply);
	}
	
	@Override
	public int update(ApplyDO apply){
		return applyDao.update(apply);
	}
	
	@Override
	public int remove(Integer id){
		return applyDao.remove(id);
	}
	
	@Override
	public int batchRemove(Integer[] ids){
		return applyDao.batchRemove(ids);
	}

	@Override
	public ApplyDO getApplyDOById(Integer id) {
		return applyDao.getApplyDOById(id);
	}

	@Override
	public List<ApplyDO> listAllByUserId(Map<String, Object> map) {
		List<ApplyDO> applyDOS=applyDao.listAllByUserId(map);
		if (applyDOS!=null&&applyDOS.size()!=0){
			for (int i=0;i<applyDOS.size();i++)
			{
				ApplyDO applyDO=applyDOS.get(i);
				if (applyDO.getIsPass()==1){
					applyDO.setContent("审核通过");
				}else if (applyDO.getIsPass()==2){
					applyDO.setContent("审核中...");
				}else{
					applyDO.setContent("审核未通过");
				}
				String [] imgs ;
				imgs=applyDO.getBookImg().split(",");
				if (imgs!=null&&imgs.length!=0){
					applyDO.setBookImg(imgs[0]);
				}
			}

		}
		return applyDOS;
	}
}
